﻿using System;
using UnityEngine;

public class Decoration : MonoBehaviour, IEditable
{
    public float height;
    private Model model;

    private void Awake()
    {
        this.model = base.GetComponent<Model>();
        this.Refresh();
    }

    public void OnDeserialize(string dataString)
    {
        JsonUtility.FromJsonOverwrite(dataString, this);
    }

    public void OnEditorGUI()
    {
        this.height = GameGUI.FloatField("Height", this.height, 1f);
        this.Refresh();
    }

    public string OnSerialize()
    {
        return JsonUtility.ToJson(this);
    }

    private void Refresh()
    {
        if (this.model != null)
        {
            this.model.SetOffset(this.model.GetOffset().SetY(this.height));
        }
    }
}

